<!DOCTYPE html>
<html>
<head>
    <title>添加药品--中软高科-2015</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="../Css/style.css" />
    <script type="text/javascript" src="../Js/jquery.js"></script>
    <script type="text/javascript" src="../Js/jquery.sorted.js"></script>
    <script type="text/javascript" src="../Js/bootstrap.js"></script>
    <script type="text/javascript" src="../Js/ckform.js"></script>
    <script type="text/javascript" src="../Js/common.js"></script>
    <script type="text/javascript" src="../Js/ckeditor/ckeditor.js"></script>


    <style type="text/css">
        body {
            padding-bottom: 40px;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }
    </style>
    <script type="text/javascript">
    $(function () {
		$('#backid').click(function(){
				window.location.href="index.html";
		 });
		$('#baocun').click(function (){
            if ($("#drId").val()==""||$("#drId").val()==null){
                alert("请填写药品编号");
                return;
            }
		    if ($("#drName").val()==""||$("#drName").val()==null){
                alert("请填写药品名称");
                return;
            }
		    let drId = $("#drId").val();
		    let drUrl = $("#drUrl").val();
		    let drInprice = $("#drInprice").val();
		    let drOutprice = $("#drOutprice").val();
		    let drName = $("#drName").val();
		    let drType = $("#drType").val();
		    let drSimdesc = $("#drSimdesc").val();
		    let drQgp = $("#drQgp").val();
		    let drDetadesc = $("#drDetadesc").val();
		    let drFatory = $("#drFatory").val();
		    let drDirection = $("#drDirection").val();
		    let drRemark = $("#drRemark").val();
		    let drNumber = 0;
		    $.ajax({
                url:"addNewDrug",
                data:{"drId":drId,"drUrl":drUrl,"drInprice":drInprice,"drOutprice":drOutprice,
                    "drName":drName,"drType":drType,"drSimdesc":drSimdesc,"drQgp":drQgp,
                    "drDetadesc":drDetadesc,"drFatory":drFatory,"drDirection":drDirection,
                    "drRemark":drRemark,"drNumber":drNumber},
                type:"post",
                dataType:"json",
                success:function (data){
                    let code = data.response.code;
                    if (code==200){
                        alert("添加成功！");
                    }else {
                        alert("添加失败！");
                    }
                    $("#drId").val("");
                    $("#drUrl").val("");
                    $("#drInprice").val("");
                    $("#drOutprice").val("");
                    $("#drName").val("");
                    $("#drType").val("");
                    $("#drSimdesc").val("");
                    $("#drQgp").val("");
                    $("#drDetadesc").val("");
                    $("#drFatory").val("");
                    $("#drDirection").val("");
                    $("#drRemark").val("");
                }
            })
        })
    });
    function uploadIMGFile(){
        let file = $("#drUrl").val();
        $.ajax({
            url: "uploadIMGFile",
            data:{"file":file},
            type: "multipart",
            success:function (data){
                let path = data.data.uri;
                $("#drUrl").val(path);
            }
        })
    }


    </script>
</head>
<body>
<form action="#" method="post" class="definewidth m20">
<table class="table table-bordered table-hover definewidth m10">
    <tr>
        <td width="10%" class="tableleft">药品编号</td>
        <td><input id="drId" type="text" name="pname" value=""/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">图片</td>
        <td><input id="drUrl" type="file" name="pname" value=""/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">进价</td>
        <td><input id="drInprice" type="text" name="pname" value=""/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">售价</td>
        <td><input id="drOutprice" type="text" name="pname" value=""/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">药品名称</td>
        <td><input id="drName" type="text" name="pname" value=""/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">药品类型</td>
        <td><input id="drType" type="radio" name="pname0" value="处方药" checked/>处方药&nbsp;&nbsp;&nbsp;<input type="radio" name="pname0" value="中药"/>中药&nbsp;&nbsp;&nbsp;<input type="radio" name="pname0" value="西药"/>西药</td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">简单描述</td>
        <td><input id="drSimdesc" type="text" name="pname" value=""/></td>
    </tr>

    <tr>
        <td width="10%" class="tableleft">保质期</td>
        <td><input id="drQgp" type="text" name="pname" value="36"/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">详细描述</td>
        <td><textarea id="drDetadesc"></textarea></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">生产厂商</td>
        <td><textarea id="drFatory"></textarea></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">服用说明</td>
        <td><input id="drDirection" type="text" name="pname" value=""/></td>
    </tr>
   
	<tr>
        <td width="10%" class="tableleft">备注</td>
        <td><textarea id="drRemark"></textarea></td>
	</tr>
    <tr>
        <td colspan="2">
			<center>
				<button id="baocun" class="btn btn-primary" type="button">保存</button> &nbsp;&nbsp;<button type="button" class="btn btn-success" name="backid" id="backid">返回列表</button>
			</center>
		</td>
    </tr>
</table>
</form>
</body>
</html>